<?
include_once('conn.php');
include_once('include/func.php');
include("admin_check.php") ;
if($admin[0][2]<>10 and $admin[0][2]<>8){exit('<script>alert("您没有权限"); window.history.back(-1);</script>');}
isset($_GET[uid])?$userdetail = $db->select("SELECT * FROM `".tablepre."user` where uid = '$_GET[uid]' "):'';
?>	
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo systemname;?></title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link href="css/admin.css" rel="stylesheet" type="text/css" />
	<!-- jquery packed -->
	<script type="text/javascript" src="js/jquery-1.4.4.js"></script>
    <script type="text/javascript" src="js/dtree.js"></script>
	<!-- tableRowCheckboxToggle -->
	<script type="text/javascript" src="js/tableRowCheckboxToggle.js"></script>
    <script type="text/javascript"> 
    function fade() 
{ 
    //停留2秒后消失,在停留的时候,透明度为1.0什么都不做 
    $('<div id="add" class="quick-alert">操作成功</div>').insertAfter($("#example")).animate({opacity: 1.0}, 2000).fadeOut("slow",function(){ 
   //隐藏时把元素删除 
   $(this).remove(); 
}); 
} 
</script> 
<?
if(isset($_GET[add])){
	$check_is_member = $db->select("SELECT id FROM `".tablepre."user` where id = '$_POST[id]' ");
	if($check_is_member[0][0]==$_POST[id]){
		exit('<script>alert("用户名已经存在"); window.history.back(-1);</script>');
		}
	$salesvolume=$_POST[salesvolume]==null?0:$_POST[salesvolume];
	$score=$_POST[score]==null?0:$_POST[score];
	$result = $db->INSERT("INSERT INTO `".tablepre."user` (`id`,`password`,`name`,`level`,`salesvolume`,`ordercount`,`advance`,`score`,`website`,`qq`,`add`,`email`,`tel`,`jointime`,`delete`,`mob`) VALUES ('$_POST[id]','".md5($_POST[password])."','$_POST[name]','$_POST[level]','$salesvolume','$_POST[ordercount]','$_POST[advance]','$score','$_POST[website]','$_POST[qq]','$_POST[add]','$_POST[email]','$_POST[tel]','".datetime."','0','$_POST[mob]')");
				header("Location: $nowpage?ok");
	exit;	
	}
	//添加
if(isset($_GET[ch])){
	$password = $_POST[password]==null?'':",`password`='".md5($_POST[password])."'";
	$upsqldate = $db->UPDATE("UPDATE `".tablepre."user` SET `name`='$_POST[name]',`level`='$_POST[level]',`salesvolume`='$_POST[salesvolume]',`ordercount`='$_POST[ordercount]',`advance`='$_POST[advance]',`score`='$_POST[score]',`website`='$_POST[website]',`qq`='$_POST[qq]',`add`='$_POST[add]',`email`='$_POST[email]',`tel`='$_POST[tel]',`mob`='$_POST[mob]' ".$password." WHERE (`uid`='$_GET[ch]')");
				header("Location: $nowpage?ok&uid=$_GET[ch]");
	exit;	
	}
	//删除
?>
</head>
<body <? echo isset($_GET[ok])?'onload="fade();"':''; ?>>
<div id="wrap">
<div id="main" class="clearfix">
<div id="side">
  </div>
  <div id="head"><? include_once('admin_head.php');?></div>
  <div id="left"><?
  include_once('admin_menu.php');
  ?></div>
  <div id="right">
<div id="example"> </div>
<form id="form2" name="form2" method="post" action="<? echo isset($_GET[uid])?'?ch='.$_GET[uid]:'?add'; ?>">
<table width="500" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">用户名</td>
    <td bgcolor="#F3F3F3"><input name="id" type="text" value="<? echo $userdetail[0][1]; ?>"  <? echo isset($_GET[uid])?'readonly="readonly"':''; ?> /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">密码</td>
    <td bgcolor="#F3F3F3"><input type="text" name="password"  /><? echo isset($_GET[uid])?'不修改密码时请留空':''; ?></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">姓名/公司名</td>
    <td bgcolor="#F3F3F3"><input type="text" name="name" value="<? echo $userdetail[0][3]; ?>"  /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">会员等级</td>
    <td bgcolor="#F3F3F3"><select name="level">
    <?
	if(isset($_GET[uid])){
	$resultnow = $db->select("SELECT vid,level FROM `".tablepre."vip` where vid = '".$userdetail[0][4]."' ");
	echo '<option value="'.$resultnow[0][0].'">'.$resultnow[0][1].'</option>';
	}
        $result = $db->select("SELECT vid,level FROM `".tablepre."vip`order by vid");
	for($i=0;$i<count($result);$i++) {
		echo '<option value="'.$result[$i][0].'">'.$result[$i][1].'</option>';
		}
	?>
    </select>
      级会员 <a href="admin_user_vip.php">[会员等级设置]</a></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">销售额</td>
    <td bgcolor="#F3F3F3"><input type="text" name="salesvolume" value="<? echo $userdetail[0][5]; ?>" /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">订单总数</td>
    <td bgcolor="#F3F3F3"><input type="text" name="ordercount" value="<? echo $userdetail[0][6]; ?>" /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">预付钱</td>
    <td bgcolor="#F3F3F3"><input type="text" name="advance" value="<? echo $userdetail[0][7]; ?>" /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">积分</td>
    <td bgcolor="#F3F3F3"><input type="text" name="score" value="<? echo $userdetail[0][8]; ?>" /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">网址</td>
    <td bgcolor="#F3F3F3"><input type="text" name="website" value="<? echo $userdetail[0][9]; ?>" /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">联系电话</td>
    <td bgcolor="#F3F3F3"><input type="text" name="tel" value="<? echo $userdetail[0][13]; ?>" /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">手机</td>
    <td bgcolor="#F3F3F3"><input type="text" name="mob" value="<? echo $userdetail[0][17]; ?>" /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">QQ</td>
    <td bgcolor="#F3F3F3"><input type="text" name="qq"  value="<? echo $userdetail[0][10]; ?>"/></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">地址</td>
    <td bgcolor="#F3F3F3"><input type="text" name="add" value="<? echo $userdetail[0][11]; ?>" /></td>
  </tr>
  <tr>
    <td align="right" valign="top" bgcolor="#F3F3F3">Email</td>
    <td bgcolor="#F3F3F3"><input type="text" name="email"  value="<? echo $userdetail[0][12]; ?>"/></td>
  </tr>
  </table>
<input type="submit" name="button2" id="button2" value="提交" />
</form>

</div>
  </div>
  </div>

<div id="footer">
<?
include_once('fooder.php');
?>
</div>
</BODY>
</HTML>
